package org.colafries.metadata.driver;

import org.colafries.common.metadata.Column;
import org.colafries.common.metadata.Schema;
import org.colafries.common.metadata.Table;
import org.colafries.metadata.convert.ITypeConvert;
import org.colafries.metadata.entity.domain.DriverConfig;
import org.colafries.metadata.query.DBQuery;
import org.colafries.metadata.result.JdbcSelectResult;

import java.util.List;


public interface Driver {
    ITypeConvert getTypeConvert();

    DBQuery getDBQuery();
    /**
     * 驱动类
     *
     * @return
     */
    String getDriverClass();

    /**
     *  数据库驱动，例如 mysql、postgresql、dm（达梦数据库）
     * @return
     */
    String getSubProtocol();

    Driver build(DriverConfig driverConfig);

    Boolean test(String user, String pwd) throws Exception;

    /**
     * 根据数据源获取Schema
     *
     * @param
     * @return
     */
    List<Schema> listSchemas();

    /**
     * 根据schema获取Table
     *
     * @param schemaName
     * @return
     */
    List<Table> listTables(String schemaName);

    /***
     * 根据schema&Table，获取Table的Column
     * @param schemaName
     * @param tableName
     * @return java.util.List<org..model.Column>
     * @author colafries
     * @Date 2024/3/24
     */
    List<Column> getTableSchema(String schemaName, String tableName);

    /***
     * 查询sql结果
     * @param sql sql表达式
     * @param current sql表达式
     * @param size -1 查询所有
     * @return org..colafries.admin.metadata.result.JdbcSelectResult
     * @author colafries
     * @Date 2024/3/24
     */
    JdbcSelectResult queryPage(String sql, Integer current, Integer size);

    /**
     * 查询sql结果schema
     * @param sql
     * @return
     * @author colafries
     * @Date 2024/4/3
     */
    List<Column> querySchema(String sql);

    /**
     * 根据查询参数生成SQL
     *
     * @param sql
     * @param queryParam
     * @return java.lang.String
     * @author colafries
     * @Date 2024/3/27
     */
//    String genQueryOption(String sql, QueryParam queryParam);

}
